package com.cxl.price.action;
import javax.annotation.Resource;

import org.apache.commons.lang.StringUtils;
import org.apache.struts2.convention.annotation.ParentPackage;

import com.cxl.price.bean.Good;
import com.cxl.price.bean.Goods;
import com.cxl.price.service.GoodService;
import com.cxl.price.service.ShopService;
import com.summer.core.action.BaseAction;
import com.summer.core.bean.Pager;

/**
 * @about: 商城商品 action
 * @author: wwwlike
 * @create: 2011-06-14
 */
 
 
@ParentPackage("price")			
public class GoodAction extends BaseAction<Good, GoodService> {

	public ShopService shopService;
	
	public String shopid;
	
	public String getShopid() {
		return shopid;
	}

	public void setShopid(String shopid) {
		this.shopid = shopid;
	}

	public void setGood(Good good) {
		setBean(good);
	}

	public Good getGood() {
		return getBean();
	}

	@Resource
	public void setShopService(ShopService shopService) {
		this.shopService = shopService;
	}
	
	@Resource
	public void setService(GoodService service) {
		this.service = service;
	}
	
	
	
public String test(){
		System.out.println("123");
		String topSession = getRequest().getParameter("top_session");
		//得到nick
		String topParameters = getRequest().getParameter("top_parameters");
		//String nick = Util.ParametersName(topParameters);
		//把sessionKey和nick写到session中，并设置session的有效期为10分钟
//		req.getSession().setAttribute("sessionKey", topSession);
//		req.getSession().setAttribute("nick", nick);
//		req.getSession().setMaxInactiveInterval(600);
//		//转到获得商品的iid页面
//		req.getRequestDispatcher("/operation/getIid.jsp").forward(req, resp);
		return "test";
	}
	
	
	public String list()
	{
		if(pager==null)
			pager=new Pager();
		String goods_id=getRequest().getParameter("goods_id");
		if(StringUtils.isNotEmpty(goods_id))
		{
			pager.setProperty("goods.id");
			pager.setKeyword(goods_id);
		}
		else{
		
		pager.setProperty("shop.id");
		pager.setKeyword(shopid);
		}
		service.findByPager(pager );
		return result(LIST);
	}


}
